<?php

require_once APPLICATION_PATH . '/modules/roles/models/HelloWorldService.php';

class Roles_WspruebaController extends Zend_Controller_Action {

    public function indexAction() {
		
	}
	
	public function serverAction()
    {
    	$this->_helper->layout->disableLayout();
        $server = new Zend_Soap_Server("http://localhost/cna/roles/wsprueba/wsdl");
        $server->setClass('HelloWorldService');
        $server->handle();
    }

    public function wsdlAction()
    {
    	$this->_helper->layout->disableLayout();
        $wsdl = new Zend_Soap_AutoDiscover();
        $wsdl->setUri('http://localhost/cna/roles/wsprueba/server');
        $wsdl->setClass('HelloWorldService');
        $wsdl->handle();
    }
	
    public function clienteAction(){
	    try {
		    //EJEMPLO LOCAL
	    	//$client = new Zend_Soap_Client("http://saces:81/cna/roles/wsprueba/wsdl"); // Servers WSDL Location
		    //$string =  $client->helloWorld();
		    //$fruits = $client->getFruits();
		    //var_dump($string);
		    //var_dump($fruits);
		    //$this->view->salidacliente=$string;
		    //$this->view->salidacliente=$fruits;
		    //Zend_Debug::dump("{$this->view->serverUrl()}/cna/wsdl/sniescna.xml");
	    	//EJEMPLO CON WEBSERVICE DESARROLLADO EN JAVA
	//	    $client = new Zend_Soap_Client("{$this->view->serverUrl()}/cna/wsdl/sniesprueba.wsdl"); // Servers WSDL Location
//		    $client = new Zend_Soap_Client("http://200.41.9.227/SniesWSPrueba/services/Version?wsdl"); // Servers WSDL Location
            //$client = new Zend_Soap_Client("http://localhost:8080/co.gov.mineducacion.snies/services/serviciosSNIESCNA?wsdl");//json
            //$client = new Zend_Soap_Client("http://localhost:8080/co.gov.mineducacion.snies/services/serviciosSNIESCNA?wsdl");//json
            
            //$client = new Zend_Soap_Client("{$this->view->serverUrl()}/cna/wsdl/sniescna.xml");
            $client = new Zend_Soap_Client("{$this->view->serverUrl()}/cna/wsdl/sniesprueba.wsdl");
            
	//	    $string =  $client->getPais();
	        $WSObtenerProgramas = new Roles_Model_WSObtenerProgramas();
	        $WSObtenerProgramas->setIesCode("1204");
	        $WSObtenerProgramas->setAnnio("2009");
	        $WSObtenerProgramas->setSemestre("02");
	        //Zend_Debug::dump($client->obtenerEstadisticasDocentes($WSObtenerProgramas));
		    //$string =  json_decode($client->obtenerEstadisticasProgramas($WSObtenerProgramas)->return);//json
		    $string =  json_decode($client->obtenerProgramasAll($WSObtenerProgramas)->return);//json
		    //$string =  json_decode($client->obtenerEstadisticasDocentes($WSObtenerProgramas)->return);//json
		    //Zend_Debug::dump($WSObtenerProgramas);
		    Zend_Debug::dump($client->getLastRequestHeaders());
		    Zend_Debug::dump($client->getLastRequest());
		    //Zend_Debug::dump($client->getLastResponse());
		    //Zend_Debug::dump($client->getFunctions());
//		    $string =  $client->getVersion();
		    $this->view->salidacliente=$string;
		} catch(Exception $e) {
		    echo $e->getMessage();
		    $this->view->salidacliente=$e->getTraceAsString();
		}
    	
    }

}

